<?php
include("./Core/Common.php");
$out_trade_no=daddslashes($_GET['out_trade_no']);
// file_put_contents(__DIR__.'/test.txt',json_encode($_REQUEST)."\n",\FILE_APPEND);

$srow = $DB->query("SELECT * FROM pay_intl_order WHERE out_trade_no='{$out_trade_no}' limit 1")->fetch();
if($srow['status']==0){
	$DB->exec("update `pay_intl_order` set `status`='1',`endtime`='{$date}' WHERE `out_trade_no`='{$out_trade_no}'");
	$Instant_row=$DB->query("SELECT * FROM pay_cloud WHERE pid='{$srow['intl_pid']}' limit 1")->fetch();
	if($Instant_row){
		if(strpos($srow['type'],'alipay') or strpos($srow['type'],'qqpay') or $srow['type']){
			$DB->exec("update `pay_cloud` set `money`=`money`-'{$srow['money']}' WHERE `pid`='{$Instant_row['pid']}'");//扣除站点额度
		}
	}
}
		$keysArr = array(
				"pid" => $_GET['pid'],
				"trade_no" => $_GET['trade_no'],
				"out_trade_no" => $_GET['out_trade_no'],
				"type" => $_GET['type'],
				"name" =>$_GET['name'],
				"money" =>$_GET['money'],
				"sign" =>$_GET['sign'],
				"sign_type" =>$_GET['sign_type']?$_GET['sign_type']:'MD5',
				"trade_status" =>$_GET['trade_status']
			);	
// file_put_contents(__DIR__.'/request.txt',$srow['notify_url'].'?'.http_build_query($keysArr)."\n",\FILE_APPEND);
echo get_curl($srow['notify_url'].'?'.http_build_query($keysArr));
?>

